﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using NNCore;

namespace NNCoreTest
{
    class Program
    {
        private double[] vector;
        public Random random;

        static void Main(string[] args)
        {
            Program main = new Program();
            main.random = new Random();
            main.Start();
        }

        public void Start()
        {
            Console.WriteLine("Gestartet");
            Controller contr = new Controller("D:/nn/buhja.xml");
            

            for (int i = 0; i < 100; i++)
            {
                double result = contr.Run(contr.CreateRandomInput());
                vector = contr.GetNetVector();
                RandomChange(vector);

                //double[] outArray = new double[10];
                //Array.Copy(vector, outArray, 10);
                //Console.WriteLine("----------------------------------------------------");
                //Console.WriteLine("Vector: " + String.Join(",", outArray.Select(p => p.ToString()).ToArray()));

                contr.SetNetAsVector(vector);
                Console.WriteLine(result);

            }
            contr.Save();
            Console.WriteLine(contr.ToString());
            Console.ReadLine();
        }

        private void RandomChange(double[] vector)
        {
            for (int i = 0; i < vector.Length; i++)
            {
                if (random.Next(0, 1) == 0)
                    vector[i] += -1 + random.NextDouble() * 2;
            }
        }


    }
}
